#ifndef __MASTER_H_
#define __MASTER_H_
#include <mutex>
#include <map>
#include "net_tool.h"
#include "Slave.h"
class LocalMaster {
    public:
        LocalMaster();
        std::map<Slave *, Slave *> slavesMap;
        void addSlave(Slave* slave);

        // 移除Slave并释放对象内存
        void removeSlave(Slave * slave);
        void printSlaves();
        // 接收来自Slave的心跳包
        void recvDoki(Slave * slave);
        void sendMsg(const char * msg);
        void sendDoki();
    private:
        std::mutex mapMutex;
};
class RemoteMaster {
    public:
        bool connected=false;
        socketinf si;
        void setSocket(socketinf si);
        void closeConnect();
        void printInfo();
        void sendDoki();
        void acceptControl();
    private:
        int doki = 0;
        std::mutex mutex;
};

extern LocalMaster localMaster;
extern RemoteMaster remoteMaster;
#endif